iMacrosControlMasterPasswordRequested Event

iMacros Component
Occurs when a macro requires a temporary master password to decrypt a password. Set the MasterPassword of MasterPasswordEventArgs to the required master password in the event handler.

Namespace:  iMacros.Component
Assembly:  iMacros.Component (in iMacros.Component.dll) Version: 12.0.501.6698
Syntax

public event MasterPasswordRequestedEventHandler MasterPasswordRequested

Value

Type: iMacros.Component.EventHelpersMasterPasswordRequestedEventHandler
Examples

The example below assumes a Form with a Panel where to add the iMacros control and a play Button with a click event
using System;
using System.Windows.Forms;
using iMacros.Component;

public partial class MainForm : Form
{
    private iMacrosControl iim;

    public MainForm()
    {
        InitializeComponent();
        iim = iMacrosControl.Create("xxxx") // Use here the license key for iMacros.Component
        iim.Dock = DockStyle.Fill;
        browserPane.Controls.Add(iim);
    }     

    private void play_Click(object sender, EventArgs e)
    {
        if (iim == null) 
            return;

        // Take care that the player is in idle mode before starting to play a macro
        if (iim.PlayerMode != PlaybackModes.Idle) 
            return;        

        // Subscribe to events which are fired during playback
        iim.MasterPasswordRequested += iim_MasterPasswordRequested;

        string macro = "CODE:URL GOTO=http://demo.imacros.net/Automate/TestForm1" + Environment.NewLine;
        macro += "SET !ENCRYPTION TMPKEY" + Environment.NewLine;
        macro += "TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:TestForm ATTR=NAME:Reg_code CONTENT=c/kdPpFFOBu3YTDs2AsJxpJCYrdIT3/RAJV4iiw1jzfar2tspVM8AQ/GFGJ4l8tqlm5+z0FcDwIVptA09Y+jZQ==";
        int res = iim.Play(macro);

        // Detach the player events
        iim.MasterPasswordRequested -= iim_MasterPasswordRequested;

        if (res == 0) // res == 0 means that the player was in playing mode when Play was called. 
            MessageBox.Show("Player is still playing");

        MessageBox.Show(String.Format("Play result is {0}", iim.ErrorText);
    }

    private void iim_MasterPasswordRequested(object sender, MasterPasswordEventArgs e)
    {
        // Handle the MasterPasswordRequested event, when iMacros needs a TEMPKEY do decrypt a temporary password
        // Set the master password 
        e.MasterPassword = "theTmpPwd";
    }
}
See Also

Reference